import {
  applyDecorators,
  Controller,
  SetMetadata,
  UseGuards,
} from '@nestjs/common';
import { Role } from '../role/entities/role.entity';
import { AuthGuard } from '@nestjs/passport';
import { RolesGuard } from './roles.guard';
import {
  ApiBearerAuth,
  ApiHeader,
  ApiSecurity,
  ApiTags,
  ApiUnauthorizedResponse,
} from '@nestjs/swagger';
// import { Role } from './enums/role.enum';

export function WitAdmin(tags, ...roles: Role[]) {
  return applyDecorators(
    Controller(tags),
    ApiTags(tags),
    // ApiHeader({
    //   name: 'token',
    //   description: 'Auth token',
    // }),
    // SetMetadata('roles', roles),
    // UseGuards(AuthGuard(), RolesGuard),
    UseGuards(AuthGuard()),
    ApiBearerAuth(),
    ApiUnauthorizedResponse({ description: '未经授权的!' }),
  );
}
